<template>
  <el-menu
    :default-active="activeIndex"
    class="el-menu-demo"
    mode="horizontal"
    :ellipsis="false"
    @select="handleSelect"
  >
    <el-menu-item index="0">合同起草</el-menu-item>
    <div class="flex-grow" />
    <el-menu-item index="1">合同类型</el-menu-item>
    <el-sub-menu index="2">
      <template #title>Workspace</template>
      <el-menu-item index="2-1">销售类合同</el-menu-item>
      <el-menu-item index="2-2">采购类合同</el-menu-item>
      <el-menu-item index="2-3">合同协议</el-menu-item>
      <el-sub-menu index="2-4">
        <template #title>item four</template>
        <el-menu-item index="2-4-1">销售类合同</el-menu-item>
        <el-menu-item index="2-4-2">采购类合同</el-menu-item>
        <el-menu-item index="2-4-3">合同协议</el-menu-item>
      </el-sub-menu>
    </el-sub-menu>
  </el-menu>
  <el-form :model="form" label-width="120px">
      <el-form-item label="合同名称">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="合同类型">
        <el-select v-model="form.region" placeholder="please select your type">
          <el-option label="采购类合同" value="shanghai" />
          <el-option label="销售类合同" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="合同时间">
        <el-col :span="11">
          <el-date-picker
            v-model="form.date1"
            type="date"
            placeholder="Pick a date"
            style="width: 100%"
          />
        </el-col>
        <el-col :span="2" class="text-center">
          <span class="text-gray-500">-</span>
        </el-col>
        <el-col :span="11">
          <el-time-picker
            v-model="form.date2"
            placeholder="Pick a time"
            style="width: 100%"
          />
        </el-col>
      </el-form-item>
      <el-form-item label="是否保存">
        <el-switch v-model="form.delivery" />
      </el-form-item>
      <el-form-item label="审批人员">
        <el-checkbox-group v-model="form.type">
          <el-checkbox label="姚三" name="type" />
          <el-checkbox label="段四" name="type" />
          <el-checkbox label="陈五" name="type" />
          <el-checkbox label="郝六" name="type" />
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="合同级别">
        <el-radio-group v-model="form.resource">
          <el-radio label="初级" />
          <el-radio label="高级" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="合同的信息">
        <el-input v-model="form.desc" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button>
        <el-button>Cancel</el-button>
      </el-form-item>
    </el-form>
  
</template>

<script  setup>
import { reactive } from 'vue'

// do not use same name with ref
const form = reactive({
  name: '',
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
})

const onSubmit = () => {
  console.log('submit!')
}
</script>

<style>
.flex-grow {
  flex-grow: 1;
}
</style>